package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * Created by 罗海量
 * 2018-07-19 21:31
 */
@Entity
@Table(name = "sys_egg")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class Egg {

    private long id;
    private long chickenId;
    private String userId;
    private int batchNum;
    private BigDecimal price;
    private int eggStatus;
    private Timestamp updateTime;
    private long version;
    private long seq;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "CHICKEN_ID")
    public long getChickenId() {
        return chickenId;
    }

    public void setChickenId(long chickenId) {
        this.chickenId = chickenId;
    }

    @Basic
    @Column(name = "USER_ID")
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "BATCH_NUM")
    public int getBatchNum() {
        return batchNum;
    }

    public void setBatchNum(int batchNum) {
        this.batchNum = batchNum;
    }

    @Basic
    @Column(name = "PRICE")
    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Basic
    @Column(name = "EGG_STATUS")
    public int getEggStatus() {
        return eggStatus;
    }

    public void setEggStatus(int eggStatus) {
        this.eggStatus = eggStatus;
    }

    @Basic
    @Column(name = "UPDATE_TIME")
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }


    @Column(name = "VERSION")
    @Version
    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Egg egg = (Egg) o;
        return id == egg.id &&
                chickenId == egg.chickenId &&
                batchNum == egg.batchNum &&
                eggStatus == egg.eggStatus &&
                version == egg.version &&
                Objects.equals(userId, egg.userId) &&
                Objects.equals(price, egg.price) &&
                Objects.equals(updateTime, egg.updateTime);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, chickenId, userId, batchNum, price, eggStatus, updateTime, version);
    }

    @Basic
    @Column(name = "SEQ")
    public long getSeq() {
        return seq;
    }

    public void setSeq(long seq) {
        this.seq = seq;
    }
}
